/**
 * 
 */
package com.hp.bon.sgw.domain;

import java.util.HashSet;
import java.util.LinkedList;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.hp.ocs.diameter.message.dictionary.AvpType;

@Entity
@Table(name = "T_BLACKLIST_RULE")
public class BlacklistRule {
	private int id;
	private String capability;
	private String keyXmlTag;
	private String rcXmlTag;
	private String rule;

	private LinkedList<AvpType> keyAvpPath = new LinkedList<AvpType>();
	private LinkedList<AvpType> rcAvpPath = new LinkedList<AvpType>();
	private HashSet<Integer> rcMap = new HashSet<Integer>();

	// @Transient
	// private HashSet<Integer> ruleSet = new LinkedList<AvpType>();

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	@Column(name = "capability", length = 64)
	public String getCapability() {
		return capability;
	}

	public void setCapability(String capability) {
		this.capability = capability;
	}

	@Column(name = "RULE", length = 256)
	public String getRule() {
		return rule;
	}

	public void setRule(String rule) {
		this.rule = rule;
	}

	@Column(name = "KEY_XMLTAG", length = 128)
	public String getKeyXmlTag() {
		return keyXmlTag;
	}

	public void setKeyXmlTag(String keyXmlTag) {
		this.keyXmlTag = keyXmlTag;
	}

	@Column(name = "RC_XMLTAG", length = 128)
	public String getRcXmlTag() {
		return rcXmlTag;
	}

	public void setRcXmlTag(String rcXmlTag) {
		this.rcXmlTag = rcXmlTag;
	}

	@Transient
	public LinkedList<AvpType> getKeyAvpPath() {
		return keyAvpPath;
	}

	public void setKeyAvpPath(LinkedList<AvpType> keyAvpPath) {
		this.keyAvpPath = keyAvpPath;
	}

	@Transient
	public LinkedList<AvpType> getRcAvpPath() {
		return rcAvpPath;
	}

	public void setRcAvpPath(LinkedList<AvpType> rcAvpPath) {
		this.rcAvpPath = rcAvpPath;
	}

	@Transient
	public HashSet<Integer> getRcMap() {
		if (rule != null) {
			String[] rc = rule.split(",");
			if (rc != null) {
				for (int i = 0; i < rc.length; i++) {
					rcMap.add(Integer.valueOf(rc[i]));
				}
			}
		}
		return rcMap;
	}

	public void setRcMap(HashSet<Integer> rcMap) {
		this.rcMap = rcMap;
	}

}